package com.example.bms.storehouse.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.example.bms.storehouse.entity.RepositoryEntity;
import com.example.bms.storehouse.service.RepositoryService;
import com.example.common.utils.PageUtils;
import com.example.common.utils.R;



/**
 * 
 *
 * @author Jiang
 * @email 337262603@qq.com
 * @date 2022-01-29 23:13:46
 */
@RestController
@RequestMapping("storehouse/repository")
@CrossOrigin
public class RepositoryController {
    @Autowired
    private RepositoryService repositoryService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("storehouse:repository:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = repositoryService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    //@RequiresPermissions("storehouse:repository:info")
    public R info(@PathVariable("id") Integer id){
		RepositoryEntity repository = repositoryService.getById(id);
        return R.ok().put("repository", repository);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("storehouse:repository:save")
    public R save(@RequestBody RepositoryEntity repository){
		repositoryService.save(repository);
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("storehouse:repository:update")
    public R update(@RequestBody RepositoryEntity repository){
		repositoryService.updateById(repository);
        return R.ok();
    }

    /**
     * 删除
     */

    @RequestMapping("/delete")
    //@RequiresPermissions("storehouse:repository:delete")
    public R delete(@RequestBody Integer[] ids){
        repositoryService.removeByIds(Arrays.asList(ids));
        return R.ok();
    }


}
